/**
 * project2
 *
 * brief description of the program
 *
 * This program is released to public domain according to
 * author's wish, you can view full license at
 * http://tomatoeskit.org/upload/PublicDomainLicense.txt
 *
 * @author Fangning CHENG (Alpha.L Cheng) <chengf@purdue.edu>
 *
 * @lab section number 
 *
 * @date Sep 16, 2013
 *
 */

import java.util.Scanner;
 
/**
 * Objectives of the Main method:
 * (1) Prompt the user to enter the double values
 *     for X1, Y1, X2, Y2, and a scalar value. 
 *     Use the Scanner to retrieve these values. 
 *     Use the first four values to create two Points
 *     (X1, Y1) and (X2, Y2). 
 * (2) Use the two Points created with user input to 
 *     create a new LineSegment with (X1, Y1) as the 
 *     start Point and (X2, Y2) as the end Point. 
 * (3) Print the following information to the user:
 *     Slope: <slope>
 *     Length: <length>
 *     Y-Intercept: <y intercept> 
 *     Equation: <y = m x + b>
 *     where the values inside of the <  > are replaced
 *     with the actual values computed using the LineSegment. 
 *     Slope, length, and Y-Intercept must be printed to 
 *     two decimal places. 
 * (4) Use the scalar value to create a new LineSegment 
 *     that is scaled by the scalar value. 
 * (5) Finally, print the following information to the user:
 *     Length After Scaling: <length of scaled LineSegment>
 *     End Point After Scaling: <new X2, Y2 of the scaled LineSegment>
 *     where the values in the <  > are replaced with 
 *     the values calculated with the new LineSegment. 
 *     The end Point is printed as follows;
 *     End Point After Scaling: <(X2, Y2)>
 *     Both length and end Point are printed to two decimal places. 
 */
public class PlaneGeometry {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        double x1;
        double x2;
        double y1;
        double y2;
        double scalar;  //Hell checkstyle
        
        
        //Use the following print statements to help implement your main method:
        //Replace the "x" with the appropriate values!!!
        System.out.println("Please enter the value for coordinate X1:\n");
        x1 = scanner.nextDouble();
        System.out.println("Please enter the value for coordinate Y1:\n");
        y1 = scanner.nextDouble();
        System.out.println("Please enter the value for coordinate X2:\n");
        x2 = scanner.nextDouble();
        System.out.println("Please enter the value for coordinate Y2:\n");
        y2 = scanner.nextDouble();
        System.out.println("Please enter the value for the scalar:\n");
        scalar = scanner.nextDouble();
        scanner.close();
        
        LineSegment lineSegment = new LineSegment(new Point(x1, y1), new Point(x2, y2));
        
        System.out.printf("Slope: %.2f\n", lineSegment.slope());
        System.out.printf("Length: %.2f\n", lineSegment.length());
        System.out.printf("Y-Intercept: %.2f\n", lineSegment.yIntercept());
        System.out.printf("Equation: " + lineSegment.toString() + "\n");
        
        LineSegment scaledLineSegment = lineSegment.scaleByFactor(scalar);
        
        System.out.printf("Length After Scaling: %.2f\n", scaledLineSegment.length());
        Point endPointOfScaledLineSegment = scaledLineSegment.getEnd();
        System.out.printf("End Point After Scaling: (%.2f, %.2f)\n", 
                endPointOfScaledLineSegment.getX(), endPointOfScaledLineSegment.getY());
    }
}
